package com.shzu.jwc.ty.controller;

import com.shzu.jwc.ty.bean.SystemYear;
import com.shzu.jwc.ty.service.SystemYearservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shzu.jwc.ty.common.Msg;
import com.shzu.jwc.ty.service.SystemConfigservice;

import java.util.List;

@RequestMapping("system")
@Controller
public class SystemConfigcontroller {

	@Autowired
	SystemConfigservice systemConfigservice;

	@Autowired
	SystemYearservice systemYearservice;
	
	@RequestMapping("/systemconfig.action")
	public String showSystemConfig(Model model)
	{
		model.addAttribute("data", systemConfigservice.getsystemconfig());
		return "system/systemconfig";
	}

	@ResponseBody
	@RequestMapping("/getYear.action")
	public List<SystemYear> getYear(){
		return systemYearservice.getSystemYear();
	}
	
	@ResponseBody
	@RequestMapping("/updatesystem.action")
	public Msg updatesystem(@RequestParam("id") Integer id,@RequestParam("value") String value)
	{
		try {
			systemConfigservice.update(id, value);
			return Msg.success("修改成功");
		}catch(Exception ex)
		{
			return Msg.error("修改失败,"+ex.getMessage());
		}
	}
}
